#!/bin/bash

export ALL_PROXY="http://192.168.31.139:7890"
export PROXY="192.168.31.139:7890"

echo "Install oh my zsh"

if  [ ! command -v ls &> /dev/null ]; then
    sudo apt install zsh
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi

cd $HOME

echo "Install python git"

if [ ! -d "$HOME/python" ]; then
    git clone https://gitee.com/trabersalnat/python.git
fi

if [ -d "$HOME/python" ]; then
    cp python/.vimrc $HOME/.vimrc
    cp python/.gitconfig $HOME/.gitconfig
fi

echo "Install useful-bin git"

if [ ! -d "$HOME/useful-bin" ]; then
    git clone https://gitee.com/trabersalnat/useful-bin.git
fi

if ! grep "useful-bin" "$HOME/.zshrc" ; then
    echo "export PATH"
    echo "export PATH=\"\$PATH:\$HOME/python\"" >> ~/.zshrc
    echo "export PATH=\"\$PATH:\$HOME/useful-bin\"" >> ~/.zshrc
    echo "export ALL_PROXY=\"http://192.168.31.139:7890\"" >> ~/.zshrc
fi

echo "Install Plug"

if [ ! -f "$HOME/.vim/autoload/plug.vim" ]; then
    curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
        https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
